Skip to content

feat(cli): add edgee relay MITM proxy rerouting inference through the gateway#123

Merged
CLEMENTINATOR merged 2 commits into
mainfrom
feat/capture-mitm
Jul 9, 2026
Merged

feat(cli): add edgee relay MITM proxy rerouting inference through the gateway#123
CLEMENTINATOR merged 2 commits into
mainfrom
feat/capture-mitm

Conversation

@SachaMorard

@SachaMorard SachaMorard commented Jun 30, 2026

Copy link
Copy Markdown
Member

What

Adds edgee relay [agent] — a local MITM proxy that reroutes LLM inference to the Edgee gateway and optionally logs the traffic, giving local visibility into requests that otherwise go straight to the gateway.

How it works

  • Terminates TLS with a locally-generated CA (rcgen), intercepts via hudsucker.
  • Reroutes inference paths to the gateway, preserving query + injecting x-edgee-api-key / x-edgee-session-id / x-edgee-repo:
    • /v1/messages, /v1/responses, /v1/chat/completions → same path on gateway
    • /backend-api/codex/responses (Codex ChatGPT backend) → remapped to /v1/responses
  • Reroute is gated by host (LLM provider domains); everything else passes through untouched.

Key & ports per agent

  • Injected Edgee key follows the relay's agent: claude for relay claude / proxy-only, codex for relay codex (keys differ per provider — they carry per-agent compression/routing settings).
  • Default ports are per-agent and uncommon so two relays coexist without --port: claude 41100, codex 41200.

Usage

edgee relay claude                    # spawn claude, reroute (port 41100, claude key)
edgee relay codex                     # spawn codex  (port 41200, codex key)
edgee relay                           # proxy-only (external clients, e.g. Claude Desktop), claude key
edgee relay claude --log-output ~/relay.log   # opt-in logging to a file
edgee launch claude --relay           # delegates to `edgee relay claude`

Running relay claude and relay codex concurrently works out of the box: each spawned agent routes only through its own relay (its HTTPS_PROXY), so keys never cross.

CA trust

  • Launched agents: injected automatically — NODE_EXTRA_CA_CERTS (Node/Claude) and CODEX_CA_CERTIFICATE (Codex/Rust). Codex's own client ignores NODE_EXTRA_CA_CERTS, hence the dedicated var.
  • External clients (proxy-only): trust the printed CA in the OS store (per-OS step).

Logging (opt-in via --log-output <file>)

  • Request + response, full bodies (no truncation), gzip/br/zstd decoded for readability.
  • Request↔response correlation ids (#N) so parallel/interleaved traffic stays readable.
  • Atomic per-block writes; the forwarded response is left byte-for-byte untouched.

Notes

  • Gated behind the relay feature (in default). Build dep aws-lc-rs needs a C toolchain (+ NASM on Windows); can fall back to ring if needed. No OS-specific code otherwise (paths via etcetera, binary resolution handles Windows).

Tests

  • Unit tests: URI rewrite + header injection, base-path prefix, Codex backend remap, gateway-URL parsing.
  • Integration smoke (witness gateway): inference rerouted with auth injected + path remapped; non-inference passed through untouched; per-agent default ports.
  • cargo fmt/clippy/test clean (default + --features relay).

🤖 Generated with Claude Code

@SachaMorard SachaMorard requested a review from a team as a code owner June 30, 2026 14:26
Comment thread crates/cli/Cargo.toml Outdated
@CLEMENTINATOR CLEMENTINATOR force-pushed the feat/capture-mitm branch 2 times, most recently from cfe7c03 to f6d12a0 Compare July 6, 2026 14:49
…gh the gateway

`edgee relay [agent]` runs a local MITM proxy that reroutes LLM inference
requests to the Edgee gateway (with x-edgee-* auth injected) and optionally logs
the traffic. Gives local visibility into requests that otherwise go straight to
the gateway.

- Reroutes /v1/messages, /v1/responses, /v1/chat/completions, and Codex's
  /backend-api/codex/responses (remapped to /v1/responses).
- Injects the agent's Edgee key: claude for `relay claude` / proxy-only, codex
  for `relay codex`. Per-agent default ports (claude 41100, codex 41200) so the
  two run side by side without `--port`.
- Per-agent CA trust: NODE_EXTRA_CA_CERTS (Node/Claude) + CODEX_CA_CERTIFICATE (Rust/Codex).
- Opt-in logging via --log-output <file> (request+response, full bodies, decoded,
  req↔response correlation ids).
- `edgee launch claude --relay` delegates to the relay.
- Gated behind the `relay` feature (in default).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@CLEMENTINATOR CLEMENTINATOR merged commit 24f2772 into main Jul 9, 2026
4 checks passed
@CLEMENTINATOR CLEMENTINATOR deleted the feat/capture-mitm branch July 9, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants